#include "comm.h"
#include "Fifo.h"
using namespace std;


int main()
{
    
    //获取key
    key_t key = GetshmkeyorDie();
    cout<<"key: "<<key<<endl;

    //创建共享内存
    int shmid = Creatshm(key,desize);
    cout<<"shmid: "<<shmid<<endl;


    //将服务端进程与共享内存挂接
    char* addr = (char*)AddshmTouch(shmid);
    cout<<"AddshmTouch Success "<<endl;

    //建立管道
    Fifo fifo;
    //可以协同
    Sync syn;
    syn.OpenReadorDie();


    //进行通信
    while(1)
    {
        if(!syn.Wait()) break;
        cout<<"shm contain:"<< addr<< endl;
    }


    //去关联
    sleep(2);
    DeshmTouch(addr);
    
    //删除共享内存
    sleep(5);
    Deleteshm(shmid);

}